<?php
namespace app\controllers;

use yii\web\Controller;
use Yii;
use app\models\say;

class SayController extends Controller{
     public $enableCsrfValidation = false;
  
     public function actionPublish(){
        $model = new say();
        if(Yii::$app->request->isPost){
           $postData = Yii::$app->request->post();
           $result = $model->add($postData);
           if( $result == 0 ){
        		$data = array('Content' => '提交数据成功');
        		echo json_encode(array('error' => 0, 'message' => 'success', 'data' => $data));
        	}else{
        		$data = array('content' => '提交数据失败,请@留言,联系公众号~', 'Content' => $result);
             	        echo json_encode(array('error' => 1, 'message' => 'fail', 'data' => $data));
                }
           }
      }
}

